package org.jili.novoland.base;

import android.graphics.Canvas;

public abstract class Layer {
	protected int x = 0; 
	protected int y = 0; 
	protected int width = 0; 
	protected int height = 0; 
	boolean visible = true; 

	public Layer(int width, int height) {
	    setSize(width, height);

	}

	public void setSize(int width, int height){
        setWidthImpl(width);
        setHeightImpl(height);
	}
	
	public void setPosition(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public void move(int dx, int dy) {
		x += dx;
		y += dy;
	}

	public final int getX() {
		return x;
	}

	public final int getY() {
		return y;
	}

	public final int getWidth() {
		return width;
	}

	public final int getHeight() {
		return height;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}

	public final boolean isVisible() {
		return visible;
	}

	public abstract void paint(Canvas c);

	void setWidthImpl(int width) {
		if (width < 0) {
			throw new IllegalArgumentException();
		}
		this.width = width;
	}

	void setHeightImpl(int height) {
		if (height < 0) {
			throw new IllegalArgumentException();
		}
		this.height = height;
	}

}
